﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>objectproperties</title>


    <!-- WinJSContrib.Core references -->
    <script src="./scripts/jquery-2.1.1.js"></script>
    <script src="./scripts/winjscontrib/jquery.mcnext.WinJS.js"></script>
    <script src="./scripts/winjscontrib/mcnext.ui.utils.js"></script>
    <script src="./scripts/winjscontrib/mcnext.ui.bindings.js"></script>

    <link href="objectproperties.css" rel="stylesheet" />
    <script src="objectproperties.js"></script>
</head>
<body>
    <div class="objectproperties fragment">
        <header aria-label="Header content" role="banner">
            <button class="win-backbutton" aria-label="Back" disabled type="button"></button>
            <h1 class="titlearea win-type-ellipsis">
                <span class="pagetitle">read/write object properties</span>
            </h1>
        </header>
        <section class="desc-screen" aria-label="Main content" role="main">
            <div class="bloc-description">
                <p>This feature is used in many of the custom bindings. The goal of this is to get a descriptor from a string or array describing an object path.</p>
                <p>
                    For example, let's says that you want to bind a zipcode you will have something like data-win-bind="innerText: address.zipcode". If you want to write your own binding, you will need a way to evaluate 'address.zipcode' on your object.
                </p>
                <p>
                    The object properties API get you a descriptor that allows reading and writing 'address.zipcode' from your object.
                </p>
            </div>
            <div class="bloc-content">
                <div>
                    <div>
                        <h3>Sample binding using object properties</h3>
                        function addClass(source, sourceProperty, dest, destProperty) {<br />
                        &nbsp;&nbsp;var data = MCNEXT.Utils.readProperty(source, sourceProperty);<br />
                        &nbsp;&nbsp;var formatParameter = bindingArguments(dest, 'format');<br />
                        &nbsp;&nbsp;if (formatParameter) {<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;dest.classList.add(formatParameter.format(data));<br />
                        &nbsp;&nbsp;}<br />
                        &nbsp;&nbsp;else {<br />
                        &nbsp;&nbsp;&nbsp;&nbsp;dest.classList.add(data);<br />
                        &nbsp;&nbsp;}<br />
                        }
                    </div>
                    <div>

                    </div>
                </div>
            </div>
        </section>
    </div>
</body>
</html>
